RelationManyList

Ecng.Serialization

Abstract base class for a many-relation list backed by IStorage.

Реализует: IRelationManyList<T>, IAsyncCollection<T>, IAsyncEnumerable<T>

Конструкторы

RelationManyList
protected RelationManyList(IStorage storage)
relationManyList = RelationManyList(storage)

Abstract base class for a many-relation list backed by IStorage.

storage
The underlying storage provider.

Свойства

BufferSize
public int BufferSize { get; set; }
value = relationManyList.BufferSize
relationManyList.BufferSize = value

Gets or sets the page size used for batched loading from storage.

BulkLoad
public bool BulkLoad { get; set; }
value = relationManyList.BulkLoad
relationManyList.BulkLoad = value

Gets or sets whether the whole list is kept in memory, filled on first access or by CancellationToken).

CacheCount
public bool CacheCount { get; set; }
value = relationManyList.CacheCount
relationManyList.CacheCount = value

Gets or sets whether to cache the entity count.

CachedEntities
public IReadOnlyDictionary<TId, TEntity> CachedEntities { get; }
value = relationManyList.CachedEntities

Read-only view of the lazily-built bulk-load cache, keyed by entity identity. Returns when the cache has not been initialised yet (e.g. before the first read on a BulkLoad list). Useful for diagnostics — and lets tests assert on cache state without reaching into private fields.

CacheTimeOut
public TimeSpan CacheTimeOut { get; set; }
value = relationManyList.CacheTimeOut
relationManyList.CacheTimeOut = value

Gets or sets the cache expiration timeout.

IsReadOnly
public virtual bool IsReadOnly { get; protected set; }
value = relationManyList.IsReadOnly
relationManyList.IsReadOnly = value

Gets or sets whether this list is read-only.

Meta
public static Schema Meta { get; }
value = RelationManyList.Meta

Gets the schema metadata for .

Storage
public IStorage Storage { get; }
value = relationManyList.Storage

Gets the underlying storage provider.

Методы

AddAsync
public ValueTask<TEntity> AddAsync(TEntity item, CancellationToken cancellationToken)
result = relationManyList.AddAsync(item, cancellationToken)

Adds a new entity to the list and storage.

ClearAsync
public ValueTask ClearAsync(CancellationToken cancellationToken)
result = relationManyList.ClearAsync(cancellationToken)

Removes all entities from the list and storage.

ContainsAsync
public abstract ValueTask<bool> ContainsAsync(TEntity item, CancellationToken cancellationToken)
result = relationManyList.ContainsAsync(item, cancellationToken)

Determines whether the list contains the specified entity.

CopyToAsync
public ValueTask CopyToAsync(TEntity[] array, int index, CancellationToken cancellationToken)
result = relationManyList.CopyToAsync(array, index, cancellationToken)

Copies entities to the specified array starting at the given index.

CountAsync
public ValueTask<int> CountAsync(bool deleted, CancellationToken cancellationToken)
result = relationManyList.CountAsync(deleted, cancellationToken)

Gets the count of entities, optionally including deleted ones.

CountAsync
public ValueTask<int> CountAsync(CancellationToken cancellationToken)
result = relationManyList.CountAsync(cancellationToken)

Gets the count of non-deleted entities.

CreateQueryable
protected virtual IQueryable<TEntity> CreateQueryable()
result = relationManyList.CreateQueryable()

Creates an IQueryable over the list data.

GetByKeyAsync``1
public ValueTask<TEntity[]> GetByKeyAsync<TKey>(Expression<Func<TEntity, TKey>> keySelector, TKey key, CancellationToken cancellationToken)
result = relationManyList.GetByKeyAsync(keySelector, key, cancellationToken)

The held rows grouped by something other than their identity, so a caller asking for "the rows of this owner" is answered by a lookup rather than by walking the whole table.

keySelector
Reads the key off a row; it also identifies the grouping, so the same one is built once and reused.
key
The key to look up.
cancellationToken
Cancellation token.

Возвращает: The rows under that key, or an empty array.

GetRangeAsync
public ValueTask<IEnumerable<TEntity>> GetRangeAsync(long startIndex, long count, bool deleted, string sortExpression, ListSortDirection direction, CancellationToken cancellationToken)
result = relationManyList.GetRangeAsync(startIndex, count, deleted, sortExpression, direction, cancellationToken)

Gets a range of entities with paging, sorting, and optional deleted filter.

IsSaved
protected abstract ValueTask<bool> IsSaved(TEntity item, CancellationToken cancellationToken)
result = relationManyList.IsSaved(item, cancellationToken)

Determines whether the specified entity has already been saved to storage.

OnAdd
protected virtual ValueTask<TEntity> OnAdd(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.OnAdd(entity, cancellationToken)

Adds an entity to the underlying storage.

OnClear
protected virtual ValueTask OnClear(CancellationToken cancellationToken)
result = relationManyList.OnClear(cancellationToken)

Clears all entities from the underlying storage.

OnGetCount
protected virtual ValueTask<long> OnGetCount(bool deleted, CancellationToken cancellationToken)
result = relationManyList.OnGetCount(deleted, cancellationToken)

Gets the total count of entities from storage.

OnGetGroup
protected virtual ValueTask<TEntity[]> OnGetGroup(long startIndex, long count, bool deleted, string orderBy, ListSortDirection direction, CancellationToken cancellationToken)
result = relationManyList.OnGetGroup(startIndex, count, deleted, orderBy, direction, cancellationToken)

Retrieves a page of entities from the underlying storage.

OnRemove
protected virtual ValueTask<bool> OnRemove(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.OnRemove(entity, cancellationToken)

Removes an entity from the underlying storage.

OnUpdate
protected virtual ValueTask<TEntity> OnUpdate(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.OnUpdate(entity, cancellationToken)

Updates an entity in the underlying storage.

PreloadAsync
public Task PreloadAsync(CancellationToken cancellationToken)
result = relationManyList.PreloadAsync(cancellationToken)

Reads the whole list into memory now, when BulkLoad asks for it to be kept there.

ReadById
public virtual ValueTask<TEntity> ReadById(TId id, CancellationToken cancellationToken)
result = relationManyList.ReadById(id, cancellationToken)

Reads an entity by its identifier.

RemoveAsync
public ValueTask<bool> RemoveAsync(TEntity item, CancellationToken cancellationToken)
result = relationManyList.RemoveAsync(item, cancellationToken)

Removes the specified entity from the list and storage.

RemoveById
public ValueTask<bool> RemoveById(TId id, CancellationToken cancellationToken)
result = relationManyList.RemoveById(id, cancellationToken)

Removes an entity by its identifier.

ResetCache
public virtual void ResetCache()
relationManyList.ResetCache()

Resets the in-memory cache, forcing data to be reloaded from storage.

SaveAsync
public ValueTask<TEntity> SaveAsync(TEntity item, CancellationToken cancellationToken)
result = relationManyList.SaveAsync(item, cancellationToken)

Saves an entity by adding it if new, or updating it if it already exists.

ToQueryable
public virtual IQueryable<TEntity> ToQueryable()
result = relationManyList.ToQueryable()

Converts the list to an IQueryable.

ToQueryableAsync
public virtual ValueTask<IQueryable<TEntity>> ToQueryableAsync(CancellationToken cancellationToken)
result = relationManyList.ToQueryableAsync(cancellationToken)

Hands the list over as a query, loading it first when it is one that is kept in memory.

cancellationToken
Cancellation token.

Возвращает: A query over the held copy for a list kept in memory, over the storage for one that is not.

TryAddAsync
public ValueTask<bool> TryAddAsync(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.TryAddAsync(entity, cancellationToken)

Tries to add an entity, returning false if it already exists.

UpdateAsync
public ValueTask<TEntity> UpdateAsync(TEntity entity, CancellationToken cancellationToken)
result = relationManyList.UpdateAsync(entity, cancellationToken)

Updates an existing entity in storage.